import request from "@/util/request";

/**
 * 获取角色权限列表
 */
export const listPermission = () => {
    return request({
        url: '/permission/listPermission',
        method: 'GET',
        headers: {
            'token': localStorage.getItem('adminToken')
        }
    });
};

/**
 * 权限树
 */
export const treePermission = () => {
    return request({
        url: '/permission/listAll',
        method: 'GET',
        headers: {
            'token': localStorage.getItem('adminToken')
        }
    });
};

/**
 * 添加权限
 */
export const addPermission = (data: {
    permissionId: string;
    permissionName: string;
    fatherPermissionId: string;
    sort: number;
}) => {
    return request({
        url: '/permission/add',
        method: 'POST',
        headers: {
            'token': localStorage.getItem('adminToken')
        },
        data
    });
};

/**
 * 删除分类
 */
export const delPermission = (permissionId: string) => {
    return request({
        url: '/permission/del',
        method: 'GET',
        headers: {
            'token': localStorage.getItem('adminToken')
        },
        params: {
            "permissionId": permissionId
        }
    });
};

/**
 * 修改权限
 */
export const modifyPermission = (data: {
    permissionId: string;
    permissionName: string;
    fatherPermissionId: string;
    sort: number;
}) => {
    return request({
        url: '/permission/modify',
        method: 'POST',
        headers: {
            'token': localStorage.getItem('adminToken')
        },
        data
    });
};







